// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0
import "functions.js" as ExtFunc

Page {
    id: addAccountPage
    tools: toolLayout

    Component.onCompleted: {
    }

    Rectangle {
        x: 0
        y: 0
        width: parent.width
        height: parent.height

        color: "black"
        opacity: 1

        Label {
            id: title
            anchors {
                top:  parent.top
                left: parent.left
                right: parent.right
                margins: 10
                topMargin: 30
            }

            color: "white"
            text: "Enter your account information"
        }

        Label {
            id: nametext
            anchors {
                top:  title.bottom
                left: parent.left
                right: parent.right
                margins: 10
                topMargin: 30
            }

            color: "white"
            text: "Account name:"
        }
        TextField {
            id: accountName
            anchors {
                top:  nametext.bottom
                left: parent.left
                right: parent.right
                margins: 10
            }
        }
        Label {
            id: keytext
            anchors {
                top:  accountName.bottom
                left: parent.left
                right: parent.right
                margins: 10
            }

            color: "white"
            text: "Secret key:"
        }
        TextField {
            id: accountSecretKey
            anchors {
                top: keytext.bottom
                left: parent.left
                right: parent.right
                margins: 10
            }
        }

        ToolBarLayout {
            id: toolLayout

            ToolButtonRow {
                id:button

                ToolButton {
                    text:"Save"
                    onClicked: {
                        if (accountName.text.length==0 || accountSecretKey.text.lenght==0) {
                            return;
                        }
                        logic.addAccount(accountName.text,accountSecretKey.text)
                        pageStack.pop()
                    }
                }
                ToolButton {
                    text:"Cancel"
                    onClicked: pageStack.pop()
                }
            }
        }
    }
}
